GBML manual / Drawing

screen_height

How many pixels tall the screen is - ask for it instead of typing a number, so a game keeps working on a screen of a different size.

Syntax

screen_height() -> int

Returns

int

Description

Gives back how many pixels tall the screen is. It is the partner of screen_width, and everything that page says about asking for the size instead of typing it applies here too: a game that asks always gets the right answer, and a game with the number typed in only works on one screen.

The screen is not the same thing as the room. room_height is how tall the whole level is, and screen_height is how tall the window you look at it through is.

Example

// a bar as tall as the screen, 4 pixels in from the top and the bottom
draw_rect_fill_anchored(ANCHOR_TOP_LEFT, 4, 4, 4, screen_height() - 8, COLOR_BLUE);

Draws a thin blue bar down the left edge that stops 4 pixels short of the top and of the bottom. It is 4 wide, and its top-left corner is 4 pixels in and 4 down, because a rectangle's position is its top-left corner. If the screen were taller, the bar would grow with it.

On the GBA

The GBA screen is 160 pixels tall, so this is 160. It is a fixed number known when the game is built, so it costs nothing at run time.

See also: screen_widthdraw_text_anchoredroom_heightScreen anchors